﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Sites/Man/Main.master" AutoEventWireup="true" CodeFile="Create.aspx.cs" Inherits="Templates_Audit_Create" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphContent" Runat="Server">
    <script type="text/javascript">
        $(document).ready(function() {
            var id = "#<%=ddlCountry.ClientID%>";
            $(id).change(function() { setUsaOnly(); });
            setUsaOnly();
            var txtEndDateId = "#<%=txtEndDate.ClientID%>";
            $(txtEndDateId).change(function() { txtEndDateChanged(); });
        }
        )

        var setUsaOnly = function() {
            var id = "#<%=ddlCountry.ClientID%> option:selected";
            var elem = $(id);
            var name = elem.text().toLowerCase().replace(/ /g, "");
            if (name == "usa" || name == "unitedstatesofamerica" || name == "unitedstates") {
                $(".usaOnly").show("fast", function() { alternateForm(); });
                $(".usaOnly span.error").each(function() { this.enabled = true; });
            }
            else {
                $(".usaOnly").hide("fast", function() { alternateForm(); });
                $(".usaOnly span.error").each(function() { this.enabled = false; });
            }
        };

//         **State date of audit removed**
//        var txtEndDateChanged = function() {
//        var datePicker = $find("<%= txtEndDate.ClientID %>");
//        var lblId = "-#-<-%-= lblStartDateValue.ClientID %->-";
//        var date = datePicker.get_selectedDate();   
//        if (date) {
//        date.setFullYear(date.getFullYear() - 1);
//        date.setDate(date.getDate() + 1);
//        $(lblId).text(date.toLocaleDateString());
//        }
//        else {
//        $(lblId).text("N/A");
//        }
//        };*/
    </script>
    <cex:RoundedBox ID="boxHead" Color="White" RoundedBottom="false" runat="server">
        <h2>Create Audit</h2>
    </cex:RoundedBox>
    <div class="spacer" style="border-top:3px solid #c2bcb6; background-color:#ffffff"></div>
    <cex:RoundedBox ID="boxBody" Color="White" RoundedTop="false" runat="server">
        <asp:Panel ID="pnlForm" CssClass="form" DefaultButton="btnCreate" runat="server">
            <div class="colA alternate">
                <ul class="col first">
                    <li class="formItem">
    	                <asp:RequiredFieldValidator ID="valCountryReq" ControlToValidate="ddlCountry" CssClass="error required" ErrorMessage="!" Display="Dynamic" ValidationGroup="CreateAudit" runat="server" />
                        <asp:Label ID="Label31" CssClass="formLabel required" runat="server" AssociatedControlID="ddlCountry" Text="Country"/>
                        <span class="formInput">
                            <asp:DropDownList ID="ddlCountry" AppendDataBoundItems="true" runat="server">
	                            <asp:ListItem Text="Select Country..." Value=""/>
	                        </asp:DropDownList>
	                   </span>
                    </li>
                    <li class="formItem usaOnly" style="display:none;">
    	                <asp:RequiredFieldValidator ID="valStateReq" ControlToValidate="ddlState" CssClass="error required" ErrorMessage="!" Display="Dynamic" ValidationGroup="CreateAudit" runat="server" />
                        <asp:Label ID="lblState" CssClass="formLabel required" runat="server" AssociatedControlID="ddlState" Text="State"/>
                        <span class="formInput">
                            <asp:DropDownList ID="ddlState" runat="server">
	                            <asp:ListItem Text=""/>
	                            <asp:ListItem Text="Idaho" Value="Idaho"/>
	                            <asp:ListItem Text="Utah" Value="Utah"/>
	                            <asp:ListItem Text="Washington" Value="Washington"/>
	                        </asp:DropDownList>
	                   </span>
                   </li>
                </ul>
                <ul class="col">
                    <li class="formItem">
                        <asp:RequiredFieldValidator ID="valEndDateReq" ControlToValidate="txtEndDate" CssClass="error required" ErrorMessage="!" ValidationGroup="CreateAudit" runat="server" />
                        <asp:Label ID="lblEndDate" CssClass="formLabel" Text="End date of the period you are measuring :" runat="server" AssociatedControlID="txtEndDate"/>
                        <asp:CompareValidator ID="valEndDateFormat" runat="server" Display="Dynamic" ErrorMessage="Invalid Date" Operator="LessThanEqual" CssClass="error" ControlToValidate="txtEndDate" Type="Date"  ValidationGroup="CreateAudit"/>
                        <span class="formInput">
                            <telerik:RadDatePicker ID="txtEndDate" runat="server" MaxDate='<%#DateTime.Today%>' />
                        </span>
                    </li>
                    <%--<li class="formItem">
                        <asp:Label ID="lblStartDate" runat="server" CssClass="formLabel" AssociatedControlID="lblStartDateValue">Start Date:</asp:Label>
                        <asp:Label ID="lblStartDateValue" CssClass="formInput" runat="server">N/A
                        </asp:Label>
                    </li>--%>
                </ul>
                <ul class="col last">
                    <li class="formItem">
                        <acms:InfoPopUp ID="info1" Text="Please include everybody, including infants." runat="server" />
                        <asp:RequiredFieldValidator ID="valNoPeopleReq" ControlToValidate="ddlNoPeople" CssClass="error required" ErrorMessage="!" ValidationGroup="CreateAudit" runat="server" />
                        <asp:Label ID="lblNoPeople" runat="server" CssClass="formLabel" AssociatedControlID="ddlNoPeople">Number of people in your household:</asp:Label>
                        <asp:CompareValidator ID="valNoPeopleFormat" Type="Integer" ControlToValidate="ddlNoPeople" Operator="GreaterThan" ValueToCompare="0" ErrorMessage="Invalid Number of People" CssClass="error" ValidationGroup="CreateAudit" runat="server"/>
                        <span class="formInput">
                            <asp:DropDownList ID="ddlNoPeople" runat="server"/>
                        </span>
                    </li>
                </ul>
                <div class="clear"></div>
            </div>
            <div class="buttons">
                <asp:Button id="btnCreate" Text="Create Audit" ValidationGroup="CreateAudit" runat="server" />
            </div>
        </asp:Panel>
    </cex:RoundedBox>
</asp:Content>

